package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 流程编码表
 * @author 代码创建
 */
public class FSysFlowNoKey extends AbstractTableBean {

    private int SysId; //租户ID
    private String AppKeyId; //应用KeyId
    private String NODesc; //编码描述
    private String NOKey; //编码Key
    private int NOStart; //起始值
    private int NONum; //现在值

    public FSysFlowNoKey (IntegrateSql f){
        super(f,"F_Sys_FlowNoKey");
        this.setKeyName("NOId");
    }

    public FSysFlowNoKey (IntegrateSql f,ResultSet rs) throws SQLException{
        super(f,"F_Sys_FlowNoKey");
        this.setKeyName("NOId");
        this.initParamToRs(rs);
    }

    public FSysFlowNoKey (IntegrateSql f,String keyValue) throws SQLException{
        super(f,"F_Sys_FlowNoKey");
        this.setKeyName("NOId");
        setCodePrepare(selectCodeById().toString());
        prepareSql.setPstValue(1, keyValue);
        ResultSet rs = executeQuery();
        if(rs.next()){
            initParamToRs(rs);
        }else{
            initParam();
        }
        rs.close();
    }

    @Override
    protected void initParam() {
        SysId = 0; //租户ID
        AppKeyId = ""; //应用KeyId
        NODesc = ""; //编码描述
        NOKey = ""; //编码Key
        NOStart = 0; //起始值
        NONum = 0; //现在值
    }


    public void initParamToRs(ResultSet rs) throws SQLException{
        SysId = rs.getInt("SysId"); //租户ID
        AppKeyId = rs.getString("AppKeyId"); //应用KeyId
        NODesc = rs.getString("NODesc"); //编码描述
        NOKey = rs.getString("NOKey"); //编码Key
        NOStart = rs.getInt("NOStart"); //起始值
        NONum = rs.getInt("NONum"); //现在值
        this.setKeyId(rs.getString("NOId"));
    }


    @Override
    protected int appendData() throws SQLException {
        int i = 1;
        prepareSql.setPstValue(i++,SysId); //租户ID
        prepareSql.setPstValue(i++,AppKeyId); //应用KeyId
        prepareSql.setPstValue(i++,NODesc); //编码描述
        prepareSql.setPstValue(i++,NOKey); //编码Key
        prepareSql.setPstValue(i++,NOStart); //起始值
        prepareSql.setPstValue(i++,NONum); //现在值
        return i;
    }


    @Override
    public Vector<String> getFields() {
        Vector<String> vec = new Vector<>();
        vec.addElement("SysId"); //租户ID
        vec.addElement("AppKeyId"); //应用KeyId
        vec.addElement("NODesc"); //编码描述
        vec.addElement("NOKey"); //编码Key
        vec.addElement("NOStart"); //起始值
        vec.addElement("NONum"); //现在值
        return vec;
    }


    /**
     * 设置租户ID
     * @param sysid
     */
    public void setSysId(int sysid){
        SysId = sysid;
    }
    /**
     * 获取SysId
     * @return 租户ID
     */
    public int getSysId(){
        return SysId;
    }

    /**
     * 设置应用KeyId
     * @param appkeyid
     */
    public void setAppKeyId(String appkeyid){
        AppKeyId = appkeyid;
    }
    /**
     * 获取AppKeyId
     * @return 应用KeyId
     */
    public String getAppKeyId(){
        return AppKeyId;
    }

    /**
     * 设置编码描述
     * @param nodesc
     */
    public void setNODesc(String nodesc){
        NODesc = nodesc;
    }
    /**
     * 获取NODesc
     * @return 编码描述
     */
    public String getNODesc(){
        return NODesc;
    }

    /**
     * 设置编码Key
     * @param nokey
     */
    public void setNOKey(String nokey){
        NOKey = nokey;
    }
    /**
     * 获取NOKey
     * @return 编码Key
     */
    public String getNOKey(){
        return NOKey;
    }

    /**
     * 设置起始值
     * @param nostart
     */
    public void setNOStart(int nostart){
        NOStart = nostart;
    }
    /**
     * 获取NOStart
     * @return 起始值
     */
    public int getNOStart(){
        return NOStart;
    }

    /**
     * 设置现在值
     * @param nonum
     */
    public void setNONum(int nonum){
        NONum = nonum;
    }
    /**
     * 获取NONum
     * @return 现在值
     */
    public int getNONum(){
        return NONum;
    }

}
